package cn.org.tpeach.nosql.tools;

import java.util.Collection;
import java.util.Map;

public class DataStructureUtils {

    public static boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.isEmpty();
    }
    public static boolean isEmpty(Map<?, ?> map) {
        return null == map || map.isEmpty();
    }

    public static boolean isEmpty(Iterable<?> iterable) {
        return null == iterable || !iterable.iterator().hasNext();
    }
    public static boolean isEmpty(Object[] array) {
        return array == null || array.length == 0;
    }


    public static boolean isNotEmpty(Collection<?> collection) {
        return !isEmpty(collection);
    }
    public static boolean isNotEmpty(Map<?, ?> map) {
        return !isEmpty(map);
    }

    public static boolean isNotEmpty(Iterable<?> iterable) {
        return !isEmpty(iterable);
    }

    public static boolean isNotEmpty(Object[] array) {
        return !isEmpty(array);
    }
    public static boolean isArray(Object object) {
        if (object == null) {
            return false;
        }
        return object.getClass().isArray();
    }
}
